package com.atguigu.dga.config;

import com.atguigu.dga.meta.service.TableMetaInfoExtraService;
import com.atguigu.dga.meta.service.TableMetaInfoService;
import com.atguigu.dga.score.service.CalScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class GovernnanceTask
{
    @Value("${assess.database.names}")
    private String datebases;
    @Autowired
    private TableMetaInfoService metaInfoService;

    @Autowired
    private TableMetaInfoExtraService metaInfoExtraService;

    @Autowired
    private CalScoreService calScoreService;

    @Scheduled(cron = "0 14 10 * * *")
    public void sheduleAssess() throws Exception {

        //上线后
        //String assessDate = LocalDate.now().toString();
        //测试
        String assessDate = "2023-05-26";

        String[] databaseNames = datebases.split(",");

        for (String databaseName : databaseNames) {
            //采集hdfs，hive的元数据。向 table_meta_info 写入每张表的元数据信息   政审(自动)
            metaInfoService.initMetaInfo(databaseName, assessDate);
            //录入辅助信息的初始值。向table_meta_info_extra写入了当天新增表的额外信息的初始值   报名(手动)
            metaInfoExtraService.initExtraMetaInfo(databaseName);
            //===========================考生已经进场=====================
            //发卷考试，算分
            calScoreService.calScore(assessDate);
        }


    }
}
